from common import *
from tables import *


# 创建表
Base.metadata.create_all(engine)

# 创建会话
Session = sessionmaker(bind=engine)
session = Session()

# # 添加数据
# new_user = User(name='John', age=30)
# session.add(new_user)
# session.commit()
#
# # 查询数据
# users = session.query(User).all()
# for user in users:
#     print(user.name, user.age)



citys = session.query(City).all()
for city in citys:
    print(city.ID, city.Name, city.CountryCode, city.District, city.Population) # 输出: 1, 城市名, 国家代码, 地区, 人口数量

# 关闭会话
session.close()
